package net.sharpf2.api.info;

import net.sharpf2.api.Globals;
import net.sharpf2.api.game.Interfaces;

/**
 *
 * @author Piotr Gajdowski
 */
public class Prayer {
    
    /**
     * Checks how much prayer points the player has left.
     * @return  int Prayer points.
     */
    public static int getPrayerPoints() {
        if (Interfaces.isInterfaceValid(749) && Globals.CLIENT.getGamestate() == 11) {
            return (int)Integer.parseInt(Interfaces.get(749, 4).getContent().getText());
        }
        return -1;
    }
    
    /**
     * Checks if prayer is enabled or not.
     * @return  Boolean True if prayer is enabled, otherwise false.
     */
    public static boolean isPrayerEnabled() {
        if (Globals.CLIENT.getSettings().getData()[1396] == 2) {
            return true;
        }
        return false;
    }
    
    /**
     * Turns quick prayers on or off, depending on the vlaue of the boolean parameter.
     * @param   onoff   True to set quick prayers on, otherwise false.
     */
    public static void turnQuickPrayers(boolean onoff) {
        if (Interfaces.isInterfaceValid(749) && Globals.CLIENT.getGamestate() == 11) {
            if (onoff == true && Globals.CLIENT.getSettings().getData()[1396] != 2) {
                Interfaces.get(749, 1).getActions().click("(Turn quick prayers on|Gebet-Schnellauswahl aktivieren|Activer)");
            } else if (onoff == false && Globals.CLIENT.getSettings().getData()[1396] != 0) {
                Interfaces.get(749, 1).getActions().click("(Turn quick prayers off|Gebet-Schnellauswahl deaktivieren|Désactiver)");
            }
        }
    }
    
    /**
     * Opens quick prayer selector interface.
     */
    public static void openQuickPrayerSelector() {
        if (Interfaces.isInterfaceValid(749) && Globals.CLIENT.getGamestate() == 11) {
            Interfaces.get(749, 1).getActions().click("(Select quick prayers|Gebet-Schnellauswahl|Choisir)");
        }
    }
    
}
